package com.blb.marrysystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.marrysystem.dao.TbUserDao;
import com.blb.marrysystem.entity.TbUser;
import com.blb.marrysystem.service.TbUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (TbUser)表服务实现类
 *
 * @author makejava
 * @since 2023-01-11 09:22:32
 */
@Service
public class TbUserServiceImpl implements TbUserService {
    @Resource
    private TbUserDao tbUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userId 主键
     * @return 实例对象
     */
    @Override
    public TbUser queryById(Integer userId) {
        return this.tbUserDao.queryById(userId);
    }

    /**
     * 分页查询
     *

     * @return 查询结果
     */
    @Override
    public Page<TbUser> queryByPage() {
    return null;
    }

    /**
     * 新增数据
     *
     * @param tbUser 实例对象
     * @return 实例对象
     */
    @Override
    public TbUser insert(TbUser tbUser) {
        this.tbUserDao.insert(tbUser);
        return tbUser;
    }

    /**
     * 修改数据
     *
     * @param tbUser 实例对象
     * @return 实例对象
     */
    @Override
    public TbUser update(TbUser tbUser) {
        this.tbUserDao.update(tbUser);
        return this.queryById(tbUser.getUserId());
    }

    /**
     * 通过主键删除数据
     *
     * @param userId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer userId) {
        return this.tbUserDao.deleteById(userId) > 0;
    }
}
